/** 
 * 2011-10-11 上午09:56:45 
 * UdpMessage.java 
 * author:sunb 
 */
package com.u6.udp.netty;

/**
 * @author sunbin
 * 
 */
public class UdpMessage {

	private short messageID;
	private short type;
	private long sendUid;
	private long receiveUid;
	private int length;
	private byte[] data;
	

	public static final int HEADER_SIZE = 24; // Message header size

	public UdpMessage(short messageID, short type, long sendUid, long receiveUid, int length, byte[] data) {
		this.messageID = messageID;
		this.type = type;
		this.sendUid = sendUid;
		this.receiveUid = receiveUid;
		this.length = length;
		this.data = data;
	}

	public short getMessageID() {
		return messageID;
	}

	public void setMessageID(short messageID) {
		this.messageID = messageID;
	}

	public short getType() {
		return type;
	}

	public void setType(short type) {
		this.type = type;
	}

	public long getSendUid() {
		return sendUid;
	}

	public void setSendUid(long sendUid) {
		this.sendUid = sendUid;
	}

	public long getReceiveUid() {
		return receiveUid;
	}

	public void setReceiveUid(long receiveUid) {
		this.receiveUid = receiveUid;
	}

	public byte[] getData() {
		return data;
	}

	public void setData(byte[] data) {
		this.data = data;
	}

	public int getPacketSize() {
		if (this.data == null) {
			return HEADER_SIZE;
		}
		return HEADER_SIZE + this.data.length;
	}

	public int getLength() {
		return length;
	}

	public void setLength(int length) {
		this.length = length;
	}

}
